<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type='text/javascript'>
        let number = 19;
        let person = {
            name:'宋',
            sex:'男'
        }

        Object.defineProperty(person,'age',{
            value:18,
            enumerable:true, //控制属性是否可枚举
            writable:true,    //可写
            configurable:true, //可删除

            //当有人读取perso的age时，就会被调用
            get(){
                return number;
            },

            //当有人修改perso的age时，就会被调用
            set(){
                return number;
            }

        })
        console.log(person)
    </script>
</body>
</html>